package com.montran.serializableFile;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class Serializable {
	public void saveData(Queue theQueue, String name) {
	
		try {
			FileOutputStream fout = new FileOutputStream(name);
			ObjectOutputStream oos = new ObjectOutputStream(fout);
			oos.writeObject(theQueue);
		
			oos.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	public Queue gerData(String name) {
		Queue theQueue;

		theQueue = new Queue();

		// unserialize the Queue
		System.out.println("unserializing theQueue");
		try {
			FileInputStream fin = new FileInputStream(name);
			ObjectInputStream ois = new ObjectInputStream(fin);
			theQueue = (Queue) ois.readObject();
			ois.close();
		} catch (Exception e) {
			e.printStackTrace();
		}

	
		return theQueue;
	}

}
